'use strict';
exports.main = async (event, context) => {
  // 最简单的云函数，用于测试基本环境
  const db = uniCloud.database();
  try {
    // 尝试创建测试记录
    const addResult = await db.collection('tenants').add({
      tenant_id: 'TEST_SIMPLE_' + Date.now(),
      tenant_name: '简单测试商户',
      contact_name: '测试联系人',
      contact_phone: '13800138000',
      status: 1,
      created_at: Date.now()
    });
    
    // 尝试查询所有记录
    const queryResult = await db.collection('tenants').limit(10).get();
    
    return {
      success: true,
      addResult,
      queryResult: queryResult.data
    };
  } catch (e) {
    return {
      success: false,
      error: e.message
    };
  }
}; 